package br.gov.cemaden.library.dao;

import br.gov.cemaden.library.model.MunicipioMonitorado;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;

/**
 *
 * @author alan
 */
public class MunicipioMonitoradoRepository {

    private EntityManager em;
    
   public MunicipioMonitoradoRepository(EntityManager em){
        this.em = em;
    }
    
    public List<MunicipioMonitorado> list(){
        try{
            return em.createQuery("FROM MunicipioMonitorado").getResultList();
        }
        catch(NoResultException ex){
            return null;
        }
    }
    
    public List<MunicipioMonitorado> list(Character status){
        try{
            return em.createQuery("FROM MunicipioMonitorado WHERE status = :status", MunicipioMonitorado.class)
                    .setParameter("status", status)
                    .getResultList();
        }
        catch(NoResultException ex){
            return null;
        }
    }
    
}
